<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="weixin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>我的发布列表</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="../../static/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="../../static/lib/bootstrapValidator/css/bootstrapValidator.min.css"/>
</head>
<body style="background-color: #31B0D5;">
<div class="container" style="margin-top: 3.125rem;">
    <div class="well well-sm">
        共有<span th:text="${pageInfo.total}">3</span>人竞争该讲座邀请
    </div>
    <div>
        <ul class="list-group">
            <li class="list-group-item" th:each="meeting : ${pageInfo.list}">
                <div class="row">
                    <div class="col-xs-9">
                        <ul class="list-group">
                            <li class="list-group-item">
                                <div class="row">
                                    <div class="col-xs-9">
                                        <a data-toggle="collapse" href="#collapseExample" th:text="${meeting.user.name}" aria-expanded="false" aria-controls="collapseExample">
                                            张三
                                        </a>
                                        <div class="collapse" id="collapseExample">
                                            <div class="well">
                                                <p th:text="${meeting.remark}">备注</p>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <a herf="#" th:href="@{/user/candidateInfo(id=${meeting.uid})}">详细资料</a>
                                    </div>
                                </div>
                            </li>
                            <li class="list-group-item">
                                抢单日期：<span th:text="${#dates.format(meeting.createTime, 'yyyy-MM-dd HH:mm')}">2019-12-23 10:49</span>
                            </li>
                        </ul>
                    </div>
                    <div class="col-xs-3">
                        <div style="margin-top: 30px">
                            <button  th:if="${meeting.matchStatus} eq '0'" class="btn btn-sm btn-danger" th:attr="data-id=${meeting.id}, data-mid=${meeting.mid}" onclick="admit(this)">就选你</button>
                            <span th:if="${meeting.matchStatus} eq '1'" class="label label-success">已选定</span>
                            <span th:if="${meeting.matchStatus} eq '2'" class="label label-danger">未选定</span>
                        </div>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <div>
        <nav aria-label="Page navigation">
            <ul class="pager">
                <li class="previous" th:if="${pageInfo.pageNum} ne '1'">
                    <a href="#" th:href="@{/meetingGrab/candidates(mid=${mid},pageNum=${pageInfo.prePage})}"><span aria-hidden="true">&larr;</span> 上一页</a>
                </li>
                <li class="next" th:if="${pageInfo.pageNum} ne ${pageInfo.pages}">
                    <a href="#" th:href="@{/meetingGrab/candidates(mid=${mid},pageNum=${pageInfo.nextPage})}">下一页 <span aria-hidden="true">&rarr;</span></a>
                </li>
            </ul>
        </nav>
    </div>
    <div id="modal01" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <strong>提示：</strong></br>
                <p>网络异常请稍后重试！</p>
            </div>
        </div>
    </div>
    <div id="modal02" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <strong>提示：</strong></br>
                <p>恭喜您，抢单成功！</p>
            </div>
        </div>
    </div>
</div>

<!--/*/<th:block th:replace="weixin/_fragments :: script">/*/-->
<script src="../../static/jquery/jquery-3.4.1.min.js" type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../../static/lib/bootstrapValidator/js/bootstrapValidator.min.js" type="text/javascript"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.6.0.js" type="text/javascript"></script>
<!--/*/</th:block>/*/-->
<script>
    function admit(obj) {
        var id = $(obj).data("id"); // 抢单编号
        var mid = $(obj).data("mid"); // 抢单的讲座编号
        var url = "/meetingGrab/confirmCandidate";
        $.post(url, {"id":id,"mid":mid}, function (msg) {
            if (msg == "1") {
                $("#modal01").modal("show"); // 发布失败
            } else if (msg == "2") {
                $("#modal02").modal("show"); // 发布成功
                setTimeout(function () {
                    window.location.reload();
                }, 1000)
            }
        })
    }
</script>
</body>
</html>
